/*
package com.cloudwise.filter;

import com.cloudwise.dao.LogDao;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

*/
/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2021/9/17 11:35
 * @description：操作日志过滤器
 * @modified By：
 * @version: 1.0
 *//*

@WebFilter(urlPatterns = "/*")
public class LogFilter implements Filter {
    LogDao logDao= new LogDaoImpl();
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest req= (HttpServletRequest) servletRequest;
        //定义一个map集合封装所有的参数名和值
        Map<String,Object> map = new HashMap();
        //获取所有的参数名集合
        Enumeration<String> parameterNames = req.getParameterNames();
        while (parameterNames.hasMoreElements()){
            String parameterName = parameterNames.nextElement();
            map.put(parameterName, req.getParameter(parameterName));
        }

     */
/*   String method = servletRequest.getParameter("method");
        String id = servletRequest.getParameter("id");
        System.out.println("操作方法："+method);
        if("delete".equals(method)){
            //处理删除操作，将删除操作的用户和事件以及删除的id记录在log日志中

                Object sessionUseranme = httpServletRequest.getSession().getAttribute("sessionUseranme");
        }*//*

        if(map.get("method")!=null){
            Map logMap= new HashMap();
            Object sessionUseranme = req.getSession().getAttribute("sessionUseranme");
            logMap.put("username",sessionUseranme);
            logMap.put("method",req.getRequestURI()+map.get("method").toString());
            logMap.put("parameter",map.toString());
            logMap.put("createtime",new Date());
            logDao.addLog(logMap);
        }

        filterChain.doFilter(servletRequest,servletResponse);

    }

    @Override
    public void destroy() {

    }
    */
/**
     * @create by: Teacher陈（86521760@qq.com）
     * @description:获取当前的字符串时间  yyyy-MM-dd HH:mm:SS
     * @create time: 2021/9/17 11:44
     * @param
     * @return java.lang.String
     *//*

    public String getTime(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");
        String format = sdf.format(new Date());
        return format;
    }
}
*/
